package com.tiens.annotation.test;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.PopupWindow;

import com.tiens.annotation.TestCode;

public class MainActivity extends AppCompatActivity {
    public View view;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus){
            showPop(1);
            showPop(2);
            showPop(3);
        }
    }
    @TestCode(author = "Tim", describe = "654466", variant = BuildConfig.BUILD_TYPE)
    void showPop(int type){
        PopupWindow popupWindow = new PopupWindow(new View(this));
        popupWindow.setOutsideTouchable(false);
        switch (type){
            case 1:
                popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
                popupWindow.setHeight(200);
                popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.BOTTOM,0,0);
                popupWindow.getContentView().setBackgroundColor(Color.rgb(255,0,0));

                break;
            case 2:
                popupWindow.setWidth(200);
                popupWindow.setHeight(200);
                popupWindow.getContentView().setBackgroundColor(Color.rgb(0,255,0));
                popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.BOTTOM|Gravity.END,20,20);
                break;
            case 3:
                popupWindow.getContentView().setBackgroundColor(Color.argb(150,0,0,255));
                popupWindow.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
                popupWindow.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
                popupWindow.showAtLocation(findViewById(android.R.id.content), Gravity.NO_GRAVITY,20,20);
                break;
        }
    }
}